package gewu.suleju.message;

import gewu.suleju.util.WebSocketProcess;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

@Component
public class MsgHandler {
    @Autowired
    private WebSocketProcess webSocketProcess;
    @Autowired
    private RedisTemplate redisTemplate;

    public void handleMessage(String brokerId){
        brokerId = brokerId.replaceAll("\"","");
        String msg = (String)redisTemplate.opsForValue().get(brokerId);
        try {
            webSocketProcess.sendMessage(Long.valueOf(brokerId),msg);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}
